var babyObj=function()
{
	var x;
	var y;
	var angle;
	this.babyEye=new Image();
	this.babyBody=new Image();
	this.babyTile=new Image();

	this.babyTailTimer=0;
	this.babyTailCount=0;

	this.babyEyeTimer=0;
	this.babyEyeCount=0;
	this.babyEyeInterval=1000;

	this.babyBodyTimer=0;
	this.babyBodyCount=0;
	this.babyBodyInterval=1000;
}
babyObj.prototype.init=function()
{
	this.x=canWidth*0.5;
	this.y=canHeight*0.5;
	this.angle=0;
	this.babyEye.src="src/babyEye0.png";
	this.babyBody.src="src/babyFade0.png";


}
babyObj.prototype.draw=function()
{
	this.x=lerpDistance(mam.x,this.x,0.98);
	this.y=lerpDistance(mam.y,this.y,0.98);

	var delteY=mam.y-this.y;
	var delteX=mam.x-this.x;
	var beta=Math.atan2(delteY,delteX)+Math.PI;

	this.angle=lerpAngle(beta,this.angle,0.6);

	this.babyTailTimer+=deltaTime;
	if(this.babyTailTimer>50)
	{
		this.babyTailCount=(this.babyTailCount+1)%8;
		this.babyTailTimer%=50;
	}

	this.babyEyeTimer+=deltaTime;
	if(this.babyEyeTimer>this.babyEyeInterval)
	{
		this.babyEyeCount=(this.babyEyeCount+1)%2;
		this.babyEyeTimer%=this.babyEyeInterval;
		if(this.babyEyeCount==0)
		{
			this.babyEyeInterval=Math.random()*1500+2000;
		}
		else
		{
			this.babyEyeInterval=200;
		}

	}

	this.babyBodyTimer+=deltaTime;
	//console.log(deltaTime);
	if(this.babyBodyTimer>300)
	{
		this.babyBodyCount=this.babyBodyCount+1;
		this.babyBodyTimer=0;
		//console.log(this.babyBodyCount);
		if(this.babyBodyCount>19)
		{
			this.babyBodyCount=19;
			data.gameover=true;
		}
		
	}


	ctx1.save();
	ctx1.translate(this.x,this.y);
	ctx1.rotate(this.angle);
	//console.log(-babyTails[this.babyTailCount].width*0.5+25);
	ctx1.drawImage(babyTails[this.babyTailCount],-babyTails[this.babyTailCount].width*0.5+25,-babyTails[this.babyTailCount].height*0.5);
	ctx1.drawImage(babyBody[this.babyBodyCount],-babyBody[this.babyBodyCount].width*0.5,-babyBody[this.babyBodyCount].height*0.5);
	ctx1.drawImage(babyEye[this.babyEyeCount],-babyEye[this.babyEyeCount].width*0.5,-babyEye[this.babyEyeCount].height*0.5);
	ctx1.restore();

}